package com.xpec.c4.service.module.task;

import com.xpec.c4.game.time.TimeSys;

/**
 * 
 * @author yangbingyan
 *
 */
public abstract class TaskTimer extends TaskObject{
	

	/**
	 * 一次
	 */
	public static final int ONCE = 0;
	
	/**
	 * 循环
	 */
	public static final int LOOP = 1;

	/**
	 * 
	 */
	private int TimerOption;

	/**
	 * 间隔时间
	 */
	private long period;
	
	/**
	 * 
	 */
	private long initialDelay;
	
	private long startTime;
	
	protected TaskTimer(){
		startTime = TimeSys.currentTimeMills();
	}
	
	public void setTimerOption(int timerOption) {
		TimerOption = timerOption;
	}

	public int getTimerOption() {
		return TimerOption;
	}

	public void setPeriod(long period) {
		this.period = period;
	}

	public long getPeriod() {
		return period;
	}

	public void setInitialDelay(long initialDelay) {
		this.initialDelay = initialDelay;
	}

	public long getInitialDelay() {
		return initialDelay;
	}
	
	public void addToExecuteQueue(){
		this.getModuleServer().addTaskObject(this);
	}
	
	@Override
	public void procTask() throws Exception {
		execute();
	}

	public long getStartTime() {
		return startTime;
	}

	public void setStartTime(long startTime) { 
		this.startTime = startTime;
	}
	
}
